/*
    This file is part of m.css.

    Copyright © 2017, 2018, 2019, 2020 Vladimír Vondruš <mosra@centrum.cz>

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
*/

a.m-doc, a.m-doc-self, a.m-doc-external,
ul.m-doc li.m-doc-expansible > a:first-child, ul.m-doc li.m-doc-collapsible > a:first-child,
.m-code.m-inverted.m-doc-include > a {
  text-decoration: none;
}
a.m-doc, a.m-doc-self {
  font-weight: bold;
}
/* Make it possible to override the above */
.m-thin a.m-doc, .m-thin a.m-doc-self {
  font-weight: normal;
}
ul.m-doc li.m-doc-expansible > a:first-child,
ul.m-doc li.m-doc-collapsible > a:first-child,
ul.m-doc li.m-doc-expansible > a:first-child:hover,
ul.m-doc li.m-doc-expansible > a:first-child:focus,
ul.m-doc li.m-doc-expansible > a:first-child:active,
ul.m-doc li.m-doc-collapsible > a:first-child:hover,
ul.m-doc li.m-doc-collapsible > a:first-child:focus,
ul.m-doc li.m-doc-collapsible > a:first-child:active {
  color: var(--color);
}
a.m-doc-self,
ul.m-doc li.m-doc-expansible > a:first-child:before,
ul.m-doc li.m-doc-collapsible > a:first-child:before {
  color: var(--article-heading-color);
}
a.m-doc-self:hover, a.m-doc-self:focus, a.m-doc-self:active,
ul.m-doc li.m-doc-expansible > a:first-child:hover::before,
ul.m-doc li.m-doc-expansible > a:first-child:focus::before,
ul.m-doc li.m-doc-expansible > a:first-child:active::before,
ul.m-doc li.m-doc-collapsible > a:first-child:hover::before,
ul.m-doc li.m-doc-collapsible > a:first-child:focus::before,
ul.m-doc li.m-doc-collapsible > a:first-child:active::before {
  color: var(--article-heading-active-color);
}
h3 a.m-doc-external {
  font-weight: normal;
}
span.m-doc-wrap-bumper {
  margin-right: -1rem;
}
span.m-doc-wrap {
  margin-left: 1rem;
  display: inline-block;
  vertical-align: text-top;
  white-space: pre-line;
  max-width: 100%; /* otherwise horizontal scrollbars, wtf */
}

/* Highlight the doc entries the same way as sections */
dl.m-doc dd {
  margin-bottom: 0.5rem;
}
dl.m-doc dd {
  margin-left: 0;
  padding-left: 2.5rem;
}
dl.m-doc dt:target, dl.m-doc dt:target + dd {
  margin-left: -1.0rem;
  border-left-style: solid;
  border-left-width: 0.25rem;
  border-color: var(--article-heading-color);
}
dl.m-doc dt:target { padding-left: 0.75rem; }
dl.m-doc dt:target + dd { padding-left: 3.25rem; }

ul.m-doc {
  list-style: none;
  margin-left:  1.0375rem;
  padding-left: 0.9rem;
  border-left-color: var(--line-color);
  border-left-width: 0.0625rem;
  border-left-style: solid;
}
ul.m-doc li {
  text-indent: -1rem;
  padding-left: 1rem;
}
ul.m-doc li.m-doc-expansible > ul {
  display: none;
}
ul.m-doc li.m-doc-expansible, ul.m-doc li.m-doc-collapsible {
  padding-left: 0.6rem;
}
ul.m-doc li.m-doc-expansible > ul.m-doc, ul.m-doc li.m-doc-collapsible > ul.m-doc {
  margin-left: 0.5rem;
}
ul.m-doc li.m-doc-expansible > a:first-child:before, ul.m-doc li.m-doc-collapsible > a:first-child:before {
  background-color: var(--background-color);
  display: inline-block;
  width: 0.4rem;
  font-weight: bold;
}
ul.m-doc li.m-doc-expansible > a:first-child:before { content: '⊕'; }
ul.m-doc li.m-doc-collapsible > a:first-child:before { content: '⊖'; }

h1 .m-doc-template, h1 .m-doc-include {
  font-size: 1.3rem;
  font-weight: normal;
}
/* If there's no template, the include is shown after in a slightly more packed
   layout */
h1 .m-doc-include:last-child {
  margin-bottom: -0.5rem;
}
h3 .m-doc-template, h3 .m-doc-include {
  font-size: 1rem;
  font-weight: normal;
}
.m-doc-template, dl.m-doc dd, ul.m-doc li > span.m-doc {
  color: var(--dim-color);
}
dl.m-doc dd svg.m-math, ul.m-doc li > span.m-doc svg.m-math {
  fill: var(--dim-color);
}
.m-doc-template a, dl.m-doc dd a, ul.m-doc li > span.m-doc a {
  color: var(--dim-link-color);
}
.m-doc-template a:hover, .m-doc-template a:focus, .m-doc-template a:active,
dl.m-doc dd a:hover, dl.m-doc dd a:focus, dl.m-doc dd a:active,
ul.m-doc li > span.m-doc a:hover, ul.m-doc li > span.m-doc a:focus, ul.m-doc li > span.m-doc a:active {
  color: var(--dim-link-active-color);
}
/* So the link gets highlighted on hover */
.m-code.m-inverted.m-doc-include > a:link,
.m-code.m-inverted.m-doc-include > a:visited {
  opacity: 0.6666; /* Same as .m-code.m-inverted > span */
}
.m-code.m-inverted.m-doc-include > a:hover,
.m-code.m-inverted.m-doc-include > a:focus,
.m-code.m-inverted.m-doc-include > a:active {
  opacity: 1;
}

article section.m-doc-details > div {
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  position: relative;
  padding: 1rem;
}
article section.m-doc-details > div::before {
  position: absolute;
  content: ' ';
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: -1; /* so it doesn't make the contents inactive */
  border-style: solid;
  border-width: 0.125rem;
  border-radius: var(--border-radius);
  border-color: var(--code-background-color);
}
article section.m-doc-details > div > h3:first-child {
  position: relative; /* so it's above the border */
  margin: -1rem -1rem 1rem -1rem;
  padding: 0.5rem 1rem;
  background-color: var(--code-background-color);
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
article section.m-doc-details:target {
  border-color: transparent; /* to preserve rounded corners */
}
article section.m-doc-details:target > div {
  z-index: 1; /* so the selection border isn't above figure border */
}

.m-container-inflatable > .m-row > [class*='m-col-'] section.m-doc-details > div {
  margin-left: -1rem;
  margin-right: -1rem;
}

.m-container-inflatable section.m-doc-details:target > div > h3:first-child,
.m-container-inflatable section.m-doc-details:target section > div > h3:first-child {
  margin-left: -1.0rem;
  border-left-style: solid;
  border-left-color: var(--article-heading-active-color);
  border-left-width: 0.25rem;
  padding-left: 0.75rem;
}
.m-container-inflatable section.m-doc-details:target > div::before,
.m-container-inflatable section-dox-details:target section > div.m::before {
  border-left-width: 0.25rem;
  border-left-color: var(--article-heading-color);
}

a.m-doc-search-icon {
  padding-left: 1rem;
  padding-right: 1rem;
}
a.m-doc-search-icon svg {
  fill: var(--header-link-color);
}
body > header > nav #m-navbar-collapse a.m-doc-search-icon svg {
  vertical-align: -5%;
}
a.m-doc-search-icon:focus svg, a.m-doc-search-icon:hover svg, a.m-doc-search-icon:active svg {
  fill: var(--header-link-active-color);
}
.m-doc-search {
  display: none;
  z-index: 10;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: var(--search-overlay-color);
}
.m-doc-search:target {
  display: block;
}
.m-doc-search > a {
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}
.m-doc-search-header {
  margin-top: 2.5rem;
  padding: 0.5rem 1rem;
  height: 2rem;
}
.m-doc-search-header > div:first-child {
  float: right;
}
.m-doc-search-content {
  background-color: var(--search-background-color);
  border-radius: var(--border-radius);
  padding: 1rem;
}
.m-doc-search input {
  width: 100%;
  height: 3rem;
  font-size: 1.2rem;
  border-width: 0;
  color: var(--color);
  background-color: var(--default-filled-background-color);
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  padding: 0 1rem; /* putting it on all sides cuts text off in FF */
}
.m-doc-search #search-notfound {
  display: none;
}
.m-doc-search ul#search-results {
  list-style-type: none;
  padding-left: 0;
  /* Size breakdown:
      2.5   margin of .m-doc-search-header from top
      2     height of .m-doc-search-header
      1     padding around .m-doc-search-header (twice 0.5rem)
      1     padding of .m-doc-search-content from top
      3     height of the input field
      1     margin under input
      1     padding of .m-doc-search-content from bottom
      1     margin under .m-doc-search-content
     ------
     12.5   total */
  max-height: calc(100vh - 12.5rem);
  overflow-y: auto;
  display: none;
}
.m-doc-search ul#search-results li a {
  display: block;
  padding-left: 1rem;
  padding-right: 1rem;
  text-decoration: none;
  width: 100%;
  line-height: 1.5rem;
  color: var(--color);
}
.m-doc-search ul#search-results li a > div {
  white-space: nowrap;
  overflow: hidden;
}
.m-doc-search ul#search-results li a > div:not(.m-doc-search-alias) {
  /* This is here in order to cut the text off at the left side. Besides this
     there's special patching needed for punctuation characters, see search.js
     for details. */
  direction: rtl;
}
.m-doc-search ul#search-results li a .m-label {
  float: right;
  line-height: 1rem;
  margin-top: 0.1rem;
  margin-left: 0.25rem;
}
.m-doc-search ul#search-results li a .m-label.m-flat {
  margin-right: -0.75rem;
}
.m-doc-search ul#search-results li#search-current a {
  background-color: var(--default-filled-background-color);
}
.m-doc-search ul#search-results li#search-current.m-doc-search-copied a {
  background-color: var(--success-filled-background-color);
}
.m-doc-search-typed {
  color: var(--link-color);
}

/* WELL THANK YOU WEBKIT! FOR SURE I WANTED ALL THAT SHIT HERE! */
.m-doc-search input[type="search"] { -webkit-appearance: textfield; }
.m-doc-search input[type="search"]::-webkit-search-decoration,
.m-doc-search input[type="search"]::-webkit-search-cancel-button,
.m-doc-search input[type="search"]::-webkit-search-results-button,
.m-doc-search input[type="search"]::-webkit-search-results-decoration {
  display: none;
}
